var io = require('socket.io').listen(3000);
io.set('log level', 1);
var users = {};
io.sockets.on('connection', function (socket) {
    console.info("client id : " + socket.client.id)
    io.sockets.emit('connect',{hell:'boy'});

    socket.on('private message', function (from,to,msg) {
        console.log('I received a private message by ', from, ' say to ',to, msg);
        if(to in users){
            users[to].emit('to'+to,{mess:msg});
        }
    });
    socket.on('new user',function(data){
        console.info(data);
        if(data in users){

        }else{
            var nickname = data;
            users[nickname]= socket;
        }

    });
    socket.on('disconnect', function () {
        io.sockets.emit('user disconnected');
    });
});